package com.minsf.springbootinit.judge;

import com.minsf.springbootinit.judge.strategy.DefaultJudgeStrategyImpl;
import com.minsf.springbootinit.judge.strategy.JavaJudgeStrategyImpl;
import com.minsf.springbootinit.judge.strategy.JudgeContext;
import com.minsf.springbootinit.judge.strategy.JudgeStrategy;
import com.minsf.springbootinit.judge.codesandbox.model.JudgeInfo;
import com.minsf.springbootinit.model.entity.QuestionSubmit;
import org.springframework.stereotype.Service;

/**
 * @Description
 * @Author minify
 * @Date 2024/3/9 22:36
 * @Project oj-backend
 */
@Service
public class JudgeManager {


    JudgeInfo doJudge(JudgeContext judgeContext) {
        QuestionSubmit questionSubmit = judgeContext.getQuestionSubmit();
        String language = questionSubmit.getLanguage();
        JudgeStrategy defaultJudgeStrategy = new DefaultJudgeStrategyImpl();
        if ("java".equals(language)) {
            defaultJudgeStrategy = new JavaJudgeStrategyImpl();
        }
        return defaultJudgeStrategy.doJudge(judgeContext);
    }
}
